using System;
using System.Collections.Generic;
using System.Text;

namespace MosziNET.Persistence
{
    /// <summary>
    /// When declared on a field or property, that member will be persisted to the database
    /// </summary>
    public class PersistedFieldAttribute : Attribute
    {
    }

    /// <summary>
    /// Specified that the field on which this
    /// attribute is defined should not be inserted
    /// or updated
    /// </summary>
    public class ReadOnlyAttribute : PersistedFieldAttribute
    {
    }

    /// <summary>
    /// Specified on the entitie's primary key.
    /// </summary>
    public class PrimaryKeyAttribute : PersistedFieldAttribute
    {
    }

    /// <summary>
    /// Specified on a field if it does not need to be persisted
    /// </summary>
    public class NotPresistedAttribute : PersistedFieldAttribute
    {
    }

    /// <summary>
    /// Specified on a class in order to tell the persistence engine
    /// to use this object instead of the class name for reading the entity
    /// </summary>
    public class ReadObjectAttribute : Attribute
    {
        string readObject;

        public ReadObjectAttribute(string readObject)
        {
            this.readObject = readObject;
        }

        public string ReadObject
        {
            get
            {
                return this.readObject;
            }
        }
    }

    /// <summary>
    /// Specified on a class in order to tell the persistence engine
    /// to use this object for writing the entity
    /// </summary>
    public class WriteObjectAttribute : Attribute
    {
        string writeObject;

        public WriteObjectAttribute(string writeObject)
        {
            this.writeObject = writeObject;
        }

        public string WriteObject
        {
            get
            {
                return this.writeObject;
            }
        }
    }

    /// <summary>
    /// When specified on an entity, the PersistenceManager will use the
    /// specified table as a read and write object.
    /// </summary>
    public class TableMappedAttribute : Attribute
    {
        string tableName;
        bool useOnlyMarkedMembers;

        /// <summary>
        /// Specify that this entity is bound to a table
        /// </summary>
        /// <param name="tableName">The table name of this entity</param>
        /// <param name="useOnlyMarkedMembers">When this parameter is true PersistenceManager will
        ///     persist only the fields and attributes which have the PersistedField attribute</param>
        public TableMappedAttribute(string tableName, bool useOnlyMarkedMembers)
        {
            this.tableName = tableName;
            this.useOnlyMarkedMembers = useOnlyMarkedMembers;
        }

        /// <summary>
        /// Returns the name of the table
        /// </summary>
        public string TableName
        {
            get { return this.tableName; }
        }

        /// <summary>
        /// Returns wether this entity will define a PersistedField attribute on each field that 
        /// has to be persisted to the database
        /// </summary>
        public bool UseOnlyMarkedMembers
        {
            get { return this.useOnlyMarkedMembers; }
        }
    }
    
}
